<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>流程节点操作配置</title>
<script type="text/javascript">
	var $grid;
	$(function() {
		$('#value').combobox({
			url : '${ctx}/pub/combobox/bpmOperation',
			method : 'get',
			editable : false,
			idField : 'value',
			textField : 'text',
			dataPlain : true
		});
		$grid = $("#grid").datagrid({
			method : "get",
			url : "${ctx}/bpm/confOperation/dataGrid?search_EQ_bpmConfNode.id=${bpmConfNodeId}",
			idField : 'id',
			remoteSort : true,
			rownumbers : true,
			multiSort : true,
			fit : true,
			toolbar : "#tt",
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'bpmConfNode',
				title : '所属流程节点',
				formatter : function(value, row, index) {
					return value ? value.name : "";
				}
			}, {
				field : 'value',
				title : '操作名称'
			}, {
				field : 'priority',
				title : '权重'
			} ] ],
			enableHeaderClickMenu : true, //此属性开启表头列名称右侧那个箭头形状的鼠标左键点击菜单
			enableHeaderContextMenu : true, //此属性开启表头列名称右键点击菜单
			enableRowContextMenu : false
		});
		$("#add").click(function() {
			$("#fm").form("clear");
			$("#fm").form("load", {
				"bpmConfNode.id" : $("#bpmConfNodeId").val()
			});
			$("#dlg").dialog("open").dialog("setTitle", "新增");
		});
		$("#delete").click(function() {
			GridDelete("#grid", "${ctx}/bpm/confOperation/delete");
		});
	});
	function fn_save() {
		var bpmConfNodeType = $("#bpmConfNodeType").val();
		var value = $('#value').combobox("getValue");
		if (bpmConfNodeType == 'userTask' && value == "保存草稿") {
			showWarnInfo("该节点类型为[用户任务]，不能设置[保存草稿]操作");
			return false;
		}
		$("#fm").form("submit", {
			url : "${ctx}/bpm/confOperation/update",
			success : function(data) {
				$grid.datagrid("load");
				$.messager.show({
					msg : data.msg,
					icon : "info",
					position : "bottomRight"
				});
				$("#dlg").dialog('close');
			}
		});
	}
</script>
</head>
<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="easyui-toolbar">
		<input type="hidden" id="bpmConfNodeId" value="${bpmConfNodeId}" />
		<a id="add" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-add'">新增</a>
		<a id="delete" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-busy'">删除</a>
	</div>
	<div id="dlg" class="easyui-dialog" style="width: 360px; height: 180px; padding: 10px 20px"
		data-options="iconCls:'icon-save',resizable:true,modal:true,inline:false, buttons:[
                    { text: '保存', iconCls: 'icon-ok', handler: function () { fn_save(); } },
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
                ],closed:true">
		<input type="hidden" id="bpmConfNodeType" value="${bpmConfNode.type }" />
		<form id="fm" method="post">
			<input type="hidden" name="id" />
			<input type="hidden" name="bpmConfNode.id" />
			<fieldset style="border: solid 1px #aaa; padding: 3px;">
				<legend>编辑</legend>
				<table id="tbl">
					<tr>
						<td>操作名称:</td>
						<td><input id="value" name="value" class="easyui-validatebox" data-options=""></td>
					</tr>
				</table>
			</fieldset>
		</form>
	</div>
</body>
</html>
